<template>
  <div class="xtx-checkbox">
    <i v-if="modelValue" class="iconfont icon-checked" @click="checkBox"></i>
    <i v-else class="iconfont icon-unchecked" @click="checkBox"></i>
    <span v-if="$slots.default"><slot /></span>
  </div>
</template>
<script>
// import { ref } from 'vue'
export default {
  name: 'XtxCheckbox',
  props: {
    modelValue: {
      type: Boolean,
      default: false
    }
  },
  setup (props, { emit }) {
    function checkBox () {
      //   props.modelValue = !props.modelValue
      emit('update:modelValue', !props.modelValue)
    }
    return {
      checkBox
    }
  }
}
</script>
<style scoped lang="less">
.xtx-checkbox {
  display: inline-block;
  margin-right: 2px;
  .icon-checked {
    color: @xtxColor;
    ~ span {
      color: @xtxColor;
    }
  }
  i {
    position: relative;
    top: 1px;
  }
  span {
    margin-left: 2px;
  }
}
</style>
